GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 50c16f...c3ede3 )
by Florian
01:20
created

Url.decode   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
c 0
b 0
f 0
nc 2
nop 1
dl 0
loc 10
rs 9.4285
1
/*jslint
2
  indent: 4
3
*/
4
/*global
5
  google, window,
6
  App, Coordinates,
7
  alpha2id
8
*/
9
10
var Url = {};
11
12
Url.getParams = function () {
13
    'use strict';
14
15
    var params = {},
16
        splitted = window.location.search.substr(1).split('&'),
17
        i,
18
        p;
19
20
    for (i = 0; i < splitted.length; i += 1) {
21
        p = splitted[i].split('=', 2);
22
        if (p[0] !== "") {
23
            if (p.length === 1) {
24
                params[p[0]] = "";
25
            } else {
26
                params[p[0]] = Url.decode(p[1]);
27
            }
28
        }
29
    }
30
31
    return params;
32
};
33
34
35
Url.decode = function (s) {
36
    'use strict';
37
38
    var s2 = decodeURIComponent(s.replace(/\+/g, " "));
39
    // allow for multiple encodings
40
    if ((s !== s2) && (/%[0-9a-fA-F]{2}/).test(s2)) {
41
        s2 = Url.decode(s2);
42
    }
43
    return s2;
44
};
45
46
47
Url.parseMarkers = function (urlarg) {
48
    'use strict';
49
50
    if (!urlarg) {
51
        return [];
52
    }
53
54
    var data;
55
56
    // ID:COODRS:R(:NAME)?|ID:COORDS:R(:NAME)?
57
    // COORDS=LAT:LON or DEG or DMMM
58
    if (urlarg.indexOf("*") >= 0) {
59
        data = urlarg.split('*');
60
    } else {
61
        /* sep is '|' */
62
        data = urlarg.split('|');
63
    }
64
65
    return data.map(function (dataitem) {
66
        dataitem = dataitem.split(':');
67
        if (dataitem.length < 3 || dataitem.length > 6) {
68
            return null;
69
        }
70
71
        var m = {
72
                alpha: dataitem[0],
73
                id: alpha2id(dataitem[0]),
74
                name: null,
75
                coords: null,
76
                r: 0,
77
                color: ""
78
            },
79
            index = 1,
80
            lat,
81
            lon;
82
83
        if (m.id < 0) {
84
            return null;
85
        }
86
87
        lat = parseFloat(dataitem[index]);
88
        lon = parseFloat(dataitem[index + 1]);
89
        if (Coordinates.valid(lat, lon)) {
90
            index += 2;
91
            m.coords = new google.maps.LatLng(lat, lon);
92
        } else {
93
            m.coords = Coordinates.fromString(dataitem[index]);
94
            index += 1;
95
        }
96
        if (!m.coords) {
97
            return null;
98
        }
99
100
        m.r = App.repairRadius(parseFloat(dataitem[index]), 0);
101
        index = index + 1;
102
103
        if (index < dataitem.length &&
104
                (/^([a-zA-Z0-9\-_]*)$/).test(dataitem[index])) {
105
            m.name = dataitem[index];
106
        }
107
108
        index = index + 1;
109
        if (index < dataitem.length &&
110
                (/^([a-fA-F0-9]{6})$/).test(dataitem[index])) {
111
            m.color = dataitem[index];
112
        }
113
114
        return m;
115
    }).filter(function (thing) {
116
        return thing !== null;
117
    });
118
};
119
120
121
Url.parseCenter = function (urlarg) {
122
    'use strict';
123
124
    if (!urlarg) {
125
        return null;
126
    }
127
128
    var data = urlarg.split(':');
129
130
    if (data.length === 1) {
131
        return Coordinates.fromString(data[0]);
132
    }
133
134
    if (data.length === 2) {
135
        return Coordinates.toLatLng(parseFloat(data[0]), parseFloat(data[1]));
136
    }
137
138
    return null;
139
};
140
141
142
Url.parseLines = function (urlarg) {
143
    'use strict';
144
145
    if (!urlarg) {
146
        return [];
147
    }
148
149
    /* be backwards compatible */
150
    if (urlarg.length === 3
151
            && alpha2id(urlarg[0]) >= 0
152
            && urlarg[1] === '*'
153
            && alpha2id(urlarg[1]) >= 0) {
154
        urlarg = urlarg[0] + ':' + urlarg[2];
155
    }
156
157
    return urlarg.split('*').map(function (pair_string) {
158
        var pair = pair_string.split(':');
159
        if (pair.length === 2) {
160
            return {source: alpha2id(pair[0]), target: alpha2id(pair[1])};
161
        }
162
        return null;
163
    }).filter(function (thing) {
164
        return (thing !== null);
165
    });
166
};
167